package com.vone.ui;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JButton;

public class MyButton extends JButton {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Color borderColor = Color.WHITE;

	public MyButton() {
		super();
		init();
	}

	public MyButton(String str) {
		super(str);
		init();
	}

	public void init() {
		this.setFocusable(false);
		this.setContentAreaFilled(false);
		this.setFocusPainted(false);
		this.setBorderPainted(false);
		this.setFont(new Font("微软雅黑", Font.PLAIN, 14));
		this.addMouseListener(new MouseAdapter() {
			// 鼠标进入事件
			public void mouseEntered(MouseEvent e) {
				setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));// 鼠标变成手型
			}

			// 鼠标移出事件
			public void mouseExited(MouseEvent e) {
				setCursor(Cursor.getDefaultCursor());// 鼠标变回默认
			}
		});
	}

	public void paint(Graphics g) {
		g.setColor(this.getBackground());
		g.fillRect(0, 0, getWidth(), getHeight());
		super.paint(g);
	}

	public void paintBorder(Graphics g) {
		g.setColor(borderColor);
		g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
	}

	public Color getBorderColor() {
		return borderColor;
	}

	public void setBorderColor(Color borderColor) {
		this.borderColor = borderColor;
	}
}
